import { request, BaseResponse } from '@/utils/request';
/**
 * @description App定义
 * @param {Namespace} isMock
 * @param isGetDataDirectly
 * @returns
 */

/**
 * 刷新数据
 * @param any
 * @returns Array
 */

export function GetTableData() {
  return request<BaseResponse<Array<Namespace.areaTableType>>>(
    {
      url: `/sys/region/getdatalist`,
      method: 'get',
    },
    {
      isMock: false,
      isGetDataDirectly: false,
    },
  );
}

/**
 * 新增数据
 * @param Namespace.areaTableType
 * @returns Array
 */

export function PostDataSave(query: Namespace.areaTableType) {
  return request<BaseResponse>(
    {
      url: '/sys/region/save',
      method: 'post',
      data: query,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '新增成功',
    },
  );
}

/**
 * 修改数据
 * @param Namespace.areaTableType
 * @returns Array
 */

export function PostEditSave(query: Namespace.areaTableType) {
  return request<BaseResponse>(
    {
      url: '/sys/region/updata',
      method: 'post',
      data: query,
      headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '修改成功',
    },
  );
}

/**
 * 修改数据
 * @param id
 * @returns {}
 */

export function PostRemove(query: { regionId: number }) {
  return request<BaseResponse>(
    {
      url: '/sys/region/remove',
      method: 'post',
      data: query,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '删除成功',
    },
  );
}

/**
 * 批量删除数据
 * @param data ID
 * @returns Array
 */

export function deleteTableList(data: Array<number>) {
  return request<BaseResponse>(
    {
      url: `/sys/region/batchremove`,
      method: 'post',
      data,
    },
    {
      isMock: false,
      isGetDataDirectly: false,
      successMsg: '删除成功',
    },
  );
}
